﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Xml;

namespace for7raid.vkPlayer
{
    public class Album
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public int OwnerId { get; set; }

        public static ObservableCollection<Album> FromResponse(XmlDocument doc)
        {

            var list = doc.SelectNodes("/response/album").OfType<XmlNode>().Select(i => new Album()
            {
                ID = i["album_id"].ParseXmlNodeAsInt(),
                OwnerId = i["owner_id"].ParseXmlNodeAsInt(),
                Title = i["title"].InnerText.Encode()
                
            });
            return new ObservableCollection<Album>(list);
        }
    }
}
